import { AxiosRequestConfig, AxiosResponse } from "axios";
import { createAxiosByInterceptors } from "../utils";

const instance = createAxiosByInterceptors({
    url: ''
});

function toRequest<T = unknown>(
    configParam: AxiosRequestConfig
) {
    return instance.request<T, AxiosResponse<T>>(configParam)
}

function toGet<T>(url: string, params: object={}) {
    return toRequest<T>({ url, params, method: 'GET' });
}

function toPost<T>(url: string, data: object={}) {
    return toRequest<T>({ url, data: data, method: 'POST' })
}

export { toGet, toPost }